package com.cashmama.market.api.infras.enums;

import com.cashmama.market.api.infras.utils.StringUtils;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-03-15 13:36
 */
public enum PackageNameEnum {
    DHANADHAN("in.dhanadhan.loan.money.cash", "DhanaDhan", "dhanadhanv6", "dhanadhan", "ddd"),
    LOANZONE("com.vayloan.app", "LoanZone", "loanzon", "loanzone", "lz"),
    CASHMAMA("in.cashmama.app", "Cashmama", "cashmama", "cashmama", "cm"),
    CREDFOX("in.credfox.lending", "DhanaDhan", "dhanadhancredfox", "dhanadhan", "ddd_new"),
    CASH_ZONE("in.cashzone.app", "CashZone", "cashzone", "cashzone", "cashzone"),
    CASHMall("com.kly.cm.mall", "CashMall", "cashmall", "cashmall", "cashmall"),
    RUPEEMAMA("com.rupeemama.app", "RupeeMama", "rupeemama", "rupeemama", "rupeemama");

    PackageNameEnum(String packageName, String desc, String prefix, String lowercaseName, String summary) {
        this.packageName = packageName;
        this.desc = desc;
        this.prefix = prefix;
        this.lowercaseName = lowercaseName;
        this.summary = summary;
    }

    private String packageName;
    private String categoryCodePackageName;
    private String desc;
    private String prefix;
    private String lowercaseName;
    private String summary;

    public String getSummary() {
        return summary;
    }

    public PackageNameEnum setSummary(String summary) {
        this.summary = summary;
        return this;
    }

    public String getLowercaseName() {
        return lowercaseName;
    }

    public PackageNameEnum setLowercaseName(String lowercaseName) {
        this.lowercaseName = lowercaseName;
        return this;
    }

    public String getPrefix() {
        return prefix;
    }

    public PackageNameEnum setPrefix(String prefix) {
        this.prefix = prefix;
        return this;
    }

    public String getPackageName() {
        return packageName;
    }

    public PackageNameEnum setPackageName(String packageName) {
        this.packageName = packageName;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public PackageNameEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static String getLowercaseAppName(String packageName) {
        if (StringUtils.isEmpty(packageName)) {
            return PackageNameEnum.DHANADHAN.getLowercaseName();
        }
        for (PackageNameEnum packageNameEnum : PackageNameEnum.values()) {
            if (packageNameEnum.getPackageName().equalsIgnoreCase(packageName)) {
                return packageNameEnum.getLowercaseName();
            }
        }
        return PackageNameEnum.DHANADHAN.getLowercaseName();
    }

    public static String getAppSummary(String packageName) {
        if (StringUtils.isEmpty(packageName)) {
            return PackageNameEnum.DHANADHAN.getSummary();
        }
        for (PackageNameEnum packageNameEnum : PackageNameEnum.values()) {
            if (packageNameEnum.getPackageName().equalsIgnoreCase(packageName)) {
                return packageNameEnum.getSummary();
            }
        }
        return PackageNameEnum.DHANADHAN.getSummary();
    }

    public static String getLowercasePackageName(String packageName) {
        if (StringUtils.isEmpty(packageName)) {
            return PackageNameEnum.DHANADHAN.getPackageName();
        }
        for (PackageNameEnum packageNameEnum : PackageNameEnum.values()) {
            if (packageNameEnum.getPackageName().equalsIgnoreCase(packageName)) {
                return packageNameEnum.getPackageName();
            }
        }
        return PackageNameEnum.DHANADHAN.getPackageName();
    }
}
